function ctrlInitArrowFormAjax(maincontext,selector, data){
	
	var form = $(selector).parents("form").eq(0);
	
	//arrowmet for ajax json error array
	
	function getFullName(name, namespace){
		if(namespace != "0")
			name =  namespace + '['+ name +']';
		return name;
	}
	
	function addError(name,error, targetNode){
		var namespace = error.namespace;
		var _alert = error.alert;
		
		name = getFullName(name,namespace);
		
		var node = form.find('[name="' + name + '"]' );
		
		if(targetNode){
			var targetName = targetNode.attr("name");
			if(name != targetName)
				return false;
		}
		
		if(!node.is(".ctrl-form-field-error")){
			node.addClass( 'ctrl-form-field-error' );
			node.after(
				$('<div class="ctrl-form-field-error-text">'+_alert.join(", ")+'</div>')
			);
		}else{
			node.next().text(_alert);
		}
	}
	
	$('input[type="text"],select,textarea,input[type="password"]', form).blur(function(){
		var input = $(this);
		setTimeout( function(){
		
		form.ajaxSubmit({
			url: $(form).attr("action") + "&arrowmet=1&arrowValidateOnly=1",
			beforeSerialize: function(){
				form.find( '[hint]' ).each(function(){
					if($(this).val() == $(this).attr("hint")){
						$(this).val("");
						$(this).removeClass("ctrl-hint");
					}
				});
				if(data.beforeSerialize)
					window[data.beforeSerialize]();
			},
			beforeSubmit:function(){
				form.find( '[hint]' ).each(function(){
					if($(this).val() == ""){
						$(this).val($(this).attr("hint"));
						$(this).addClass("ctrl-hint");
					}
				});
				
			},
			
			
			success:function(responseText, statusText, xhr, $form){
				var obj = eval(responseText);
				
				$(".ctrl-form-field-error",form).each(function(){
					var currName = $(this).attr("name");
					var removeError = true;
					for(i in obj.error.errors){
						 if( currName == getFullName(i,obj.error.errors[i].namespace))
							 removeError = false;
					}
					if(removeError){
						$(this).next(".ctrl-form-field-error-text").remove();
						$(this).removeClass("ctrl-form-field-error");
					}
					
				});
				
				for(i in obj.error.errors)
					addError(i, obj.error.errors[i], input);
				
				
				
			}
		});
		
		}, 50 );
	});
	
	
	
	form.ajaxForm({
		url: $(form).attr("action") + "&arrowmet=1",
		
		beforeSerialize: function(){
			form.find( '[hint]' ).each(function(){
				if($(this).val() == $(this).attr("hint")){
					$(this).val("");
					$(this).removeClass("ctrl-hint");
				}
			});
			if(data.beforeSerialize)
				window[data.beforeSerialize]();
		},
		beforeSubmit:function(){
			form.find( '[hint]' ).each(function(){
				if($(this).val() == ""){
					$(this).val($(this).attr("hint"));
					$(this).addClass("ctrl-hint");
				}
			});
			
			if(window[data.beforeSubmit])
				window[data.beforeSubmit]();
			
			form.find("input[type='sumbit']").hide();
			
		},
		success:function(responseText, statusText, xhr, $form){
			
			if(data.debugTarget)
				$(data.debugTarget).text( ""+  responseText);
			
			var obj = eval(responseText);
			if(obj == undefined)
				alert('ArrowFormAjax:: Nieprawidłowa odpowiedź serwera.');
			
			$(".ctrl-form-field-error-text",form).remove();
			$(".ctrl-form-field-error",form).removeClass("ctrl-form-field-error");
			
			if(obj.error){
				
				for(i in obj.error.errors)
					addError(i, obj.error.errors[i]);
				
				if(data.error)
					window[data.error](form, obj.error);
				
				form.find("input[type='sumbit']").show();
				
			}else{
				if(data.success)
					window[data.success](form, responseText);
				
				if(data.target && data.targetText)
					$(data.target).html(data.targetText);
			}
			
		}
    }); 
		
	
}